package com.yeban.javase.day12.test.streamtest;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/22
 *
 * 3.筛选员工中工资高于8000的人，并形成新的集合
 */
public class StreamTest03 {

    public static void main(String[] args) {
        List<Employee> employees = Arrays.asList (
                new Employee ("张三", 7500.0),
                new Employee ("李四", 8200.0),
                new Employee ("王五", 9000.0),
                new Employee ("赵六", 7800.0),
                new Employee ("孙七", 10000.0));

        List<Employee> newList = employees.stream().filter(s -> s.getSalary() > 8000).collect(Collectors.toList());
        System.out.println(newList);
    }
}

class Employee {
    private String name;
    private Double salary;

    public Employee() {
    }

    public Employee(String name, Double salary) {
        this.name = name;
        this.salary = salary;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return salary
     */
    public Double getSalary() {
        return salary;
    }

    /**
     * 设置
     * @param salary
     */
    public void setSalary(Double salary) {
        this.salary = salary;
    }

    public String toString() {
        return "Employee{name = " + name + ", salary = " + salary + "}";
    }
}
